﻿using PTop.Application.Article;
using PTop.Code;
using PTop.Domain.Entity.Article;
using System.Web.Mvc;

namespace PTop.Web.Areas.Article.Controllers
{
    public class TagController : ControllerBase
    {
        private TagApp _app = new TagApp();

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(Pagination pagination, string articleId)
        {
            var data = _app.GetList(pagination, articleId);
            return PageContent(pagination.records, pagination.rows, data);
        }
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = _app.GetForm(keyValue);
            return Content(data.ToJson());
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        public ActionResult SubmitForm(TagEntity entity, string keyValue)
        {
            _app.SubmitForm(entity, keyValue);
            return Success("操作成功。");
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            _app.Delete(keyValue);
            return Success("删除成功。");
        }
    }
}
